<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function formatDate($dateStr, $format = 'h:i, d/m/Y') {
    $date = new DateTime($dateStr);
    return $date->format($format);
}

function add_date($givendate, $day=0, $mth=0, $yr=0) {
    $cd = strtotime($givendate);
    $newdate = date('Y-m-d h:i:s', mktime(date('h', $cd),
    date('i', $cd), date('s', $cd), date('m', $cd) + $mth,
    date('d', $cd) + $day, date('Y', $cd) + $yr));
    return substr($newdate, 0, 10);
}

function render_date($intval, $format = 'd/m/Y') {
    if (empty($intval)) {
        return date($format);
    }
    return date($format, $intval);
}

function get_time_stamp($date, $point = 0)
{
    $date = explode('/', $date);

    if ($point == 0) {
        $extend = ' 00:00:00';
    } else {
        $extend = ' 23:59:59';
    }

    $date = $date['2'] . '-' . $date['1'] . '-' . $date['0'] . $extend;
    $date = strtotime($date);
    return $date;
}

function render_two_digits($value) {
    if (intval($value) < 10) {
        return '0' . intval($value);
    }
    return $value;
}
?>
